<?php

/**
 * zMail actions.
 *
 * @package    sf_sandbox
 * @subpackage zMail
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class zMailActions extends sfActions
{
    /**
     * Executes index action
     *
     */
    public function executeIndex()
    {
        /* ********* */

        error_reporting(E_STRICT);

        date_default_timezone_set(date_default_timezone_get());
        var_dump("init1");
        include_once('class.phpmailer.php');
        var_dump("init2");
        $mail = new PHPMailer();
        $mail->IsMail(); // telling the class to use SMTP
        $mail->Host = Globals::EMAIL_HOST; // SMTP server
        $mail->Sender = Globals::EMAIL_FROM_NOREPLY;
        $mail->From = Globals::EMAIL_FROM_NOREPLY;
        $mail->FromName = Globals::EMAIL_FROM_NOREPLY_NAME;

        $mail->Subject = "Registration email notification";
        var_dump("init3");
        $body = "Dear <jason>,<p><p>

        <p>Your registration request has been successfully sent to Maple Grow International Group</p>

        <p>User ID: </p>";

        $text_body = $body;

        $mail->Body = $body;
        $mail->AltBody = $text_body;
        $mail->AddAddress("r9projecthost@gmail.com", "r9projecthost");
        var_dump("ready");
        if (!$mail->Send()) {
            echo $mail->ErrorInfo;
        } else {
            var_dump("done");
        }
    }

    public function executeSendmail()
    {
        // class initialization
        $mail = new sfMail();
        $mail->initialize();
        $mail->setMailer('sendmail');
        $mail->setCharset('utf-8');

        // definition of the required parameters
        $mail->setHostname(Globals::EMAIL_HOST);
        $mail->setSender(Globals::EMAIL_FROM_NOREPLY, "Host");
        $mail->setFrom(Globals::EMAIL_FROM_NOREPLY, 'My Company');
        $mail->addReplyTo('webmaster_copy@my-company.com');

        $mail->addAddress("coolsky84@gmail.com", "test");

        $mail->setSubject('Your password request');
        $mail->setBody('
  Dear customer,

  You are so absentminded. Next time, try to remember your password:
  pukima

  Regards,
  The My Company webmaster');

        // send the email
        $mail->send();
    }
}
